package com.cskaoyan.controller.advertising;

import com.cskaoyan.bean.bo.AdminTopicCreateBo;
import com.cskaoyan.bean.bo.AdminTopicDeleteBo;
import com.cskaoyan.bean.bo.AdminTopicUpdateBo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.vo.AdminTopicCreateVo;
import com.cskaoyan.bean.vo.AdminTopicListVo;
import com.cskaoyan.bean.vo.AdminTopicReadVo;
import com.cskaoyan.bean.vo.AdminTopicUpdateVo;
import com.cskaoyan.service.AdvertisingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("admin/topic")
public class AdvertisingTopicController {
    @Autowired
    AdvertisingService advertisingService;

    /**
     * @Description: 获取专题管理表
     * @Description: /admin/topic/list
     * @date: 2022/9/7 23:25
     * @author: zyc
     * @since JDK 1.8
     */
    @GetMapping("list")
    public BaseRespVo getTopicList(Integer page,Integer limit,String title,String subtitle,String sort,String order){
        AdminTopicListVo topicListVo = advertisingService.getTopicList(page,limit,title,subtitle,sort,order);
        return BaseRespVo.ok(topicListVo);
    }

    /**
     * @Description: 创建专题信息
     * @Description: /admin/topic/create
     * @date: 2022/9/8 8:28
     * @author: zyc
     * @since JDK 1.8
     */
    @PostMapping("create")
    public BaseRespVo createTopic(@RequestBody AdminTopicCreateBo createBo){
        AdminTopicCreateVo createVo = advertisingService.createTopic(createBo);
        return BaseRespVo.ok(createVo);
    }

    /**
     * @Description: 回显专题信息
     * @Description: /admin/topic/read
     * @date: 2022/9/8 8:58
     * @author: zyc
     * @since JDK 1.8
     */
    @GetMapping("read")
    public BaseRespVo readTopic(Integer id){
        AdminTopicReadVo readVo = advertisingService.readTopic(id);
        return BaseRespVo.ok(readVo);
    }

    /**
     * @Description: 更新专题信息
     * @Description: /admin/topic/update
     * @date: 2022/9/8 9:10
     * @author: zyc
     * @since JDK 1.8
     */
    @PostMapping("update")
    public BaseRespVo updateTopic(@RequestBody AdminTopicUpdateBo updateBo){
        AdminTopicUpdateVo updateVo = advertisingService.updateTopic(updateBo);
        return BaseRespVo.ok(updateVo);
    }

    /**
     * @Description: 删除专题信息
     * @Description: /admin/topic/delete
     * @date: 2022/9/8 9:23
     * @author: zyc
     * @since JDK 1.8
     */
    @PostMapping("delete")
    public BaseRespVo deleteTopic(@RequestBody AdminTopicDeleteBo deleteBo){
        advertisingService.deleteTopic(deleteBo);
        return BaseRespVo.ok();
    }
}
